<?php get_header(); ?>
	<!-- BEGIN SLIDER -->
	  <div id="slider">
	  		<?php if(get_option('boldy_slider')!=''){
			$page_data = get_page(get_option('boldy_slider'));
					$content = $page_data->post_content;
					echo $page_data->post_content;
			}else{?>
				<div style="border:1px solid #ddd; text-align:center; padding:150px 100px 0; height:219px; font-size:14px;">
					Bổ sung hình ảnh cho slider (960x370)
				</div>
			<?php }?>
		</div>
	   <div style="width:960px; margin:0 auto; background:url(<?php bloginfo('template_directory'); ?>/images/bk_shadow_slider.png) 0 0 no-repeat; height:50px;"></div>
	   <!-- END SLIDER -->
	   <!-- BEGIN HOME CONTENT -->
	   <!-- begin home boxes -->
		<?php $box1=get_post(get_option('boldy_home_box1'));
				  $box2=get_post(get_option('boldy_home_box2'));
				  $box3=get_post(get_option('boldy_home_box3')); 
				  if(get_option('boldy_home_box1')!= null && get_option('boldy_home_box2')!= null && get_option('boldy_home_box3')!= null){?>
		<div id="homeBoxes" class="clearfix">
			<div class="homeBox">
				<h2><?php echo $box1->post_title?></h2>
                <div class="jk_nav"></div>
				<?php echo apply_filters('the_content', $box1->post_content);?>
				<a href="<?php echo get_option('boldy_home_box1_link')?>"><strong>Xem thêm &raquo;</strong></a>
			</div>
			<div class="homeBox">
				<h2><?php echo $box2->post_title?></h2>
                <div class="jk_nav"></div>
				<?php echo apply_filters('the_content', $box2->post_content);?>
				<a href="<?php echo get_option('boldy_home_box2_link')?>"><strong>Xem thêm &raquo;</strong></a>
			</div>
			<div class="homeBox last">
				<h2><?php echo $box3->post_title?></h2>
                <div class="jk_nav"></div>
				<?php echo apply_filters('the_content', $box3->post_content);?>
				<a href="<?php echo get_option('boldy_home_box3_link')?>"><strong>Xem thêm &raquo;</strong></a>
			</div>
		</div>
		<?php }?>
		<!-- end home boxes -->
         <!-- BEGIN BLURB -->
	   <?php if(get_option('boldy_blurb_enable')=="yes" && get_option('boldy_blurb_text')!=""){ ?>
	   <div id="blurb">
			<p>
			<a href="<?php 
			if(get_option('boldy_blurb_page')!=""){
				echo get_permalink(get_option('boldy_blurb_page'));
			}elseif(get_option('boldy_blurb_link')!=""){
				echo get_option('boldy_blurb_link');
			} ?>"><img src="<?php bloginfo('template_directory'); ?>/images/but_blurb.png" alt="" /></a>
			<?php echo get_option('boldy_blurb_text'); ?> 
			</p>
	   </div>
	   <?php }?>
	   <!-- END BLURB -->
       <!-- NEWS -->
       <script type="text/javascript" language="javascript">
			$(function() {
				$('#ul_khuyenmai').carouFredSel({
					
					scroll:1000					
				});
			});
		</script>	
       <div id="news">
           <div class="bangrol"></div>
                <div class="block_khuyenmai">
                	<ul id="ul_khuyenmai">
					<?php
					$args = array( 'meta_key'   =>  'check_home',
						 		   'meta_value' => 'on' );
					$postslist = get_posts( $args );
					foreach ($postslist as $post) :  setup_postdata($post); ?> 
                		<li>
                   	 <a href="<? the_permalink()?>" title="<?php the_title(); ?>">
                     	<img alt="<?php the_title(); ?> " title="<?php the_title(); ?> " src=" <?= get_post_meta(get_the_ID(),'image',true)?>" />
                     </a>
                   	<p class="des_khuyenmai">
                    <a href="<? the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>  
                    <?php //the_excerpt(); hàm lấy 1 phan dau cua noi dung ?>
                    </p>
						</li>
				<?php endforeach; ?>
                	</ul>
           </div>
       </div>
       <!-- END NEWS -->
        <!-- Sản phẩm đặc biệt -->
      
       <script type="text/javascript" language="javascript">
			$(function() {
				$('#new_product_list').carouFredSel({
					scroll:800,
					prev: '#prevs',
					next: '#nexts',
				
					
				});
			});
			
			$(function() {
				$('#best_sell_list').carouFredSel({
					scroll:2000,					  
					prev: '#prevs2',
					next: '#nexts2',
					auto: false
					
					
				});
			});
			$(document).ready(function(){
			$('img.captify').captify({
				speedOver: 'fast',
				speedOut: 'normal',
				hideDelay: 500,	
				animation: 'slide',		
				prefix: '',		
				opacity: '0.7',					
				className: 'caption-bottom',	
				position: 'bottom',
				spanWidth: '100%'
			});
		});
		</script>
        <div id="jk-feature-product">
        	<h2>Sản phẩm mới</h2>
            <div class="jk_nav"></div>
            <div class="jk-list-product">            	
            	<ul id="new_product_list">
                <?php
					
					$arg = array('post_type'         => 'san-pham',
								 'meta_key'          =>  'sanpham_moi',
								 'meta_value' 	     => 'on',
                                 );
					$wp_query = new WP_Query($arg);
					
					if($wp_query->have_posts())
					{
						while($wp_query->have_posts())
						{
							$wp_query->the_post();
								if(get_post_meta(get_the_ID(),'primary_image',true) !=''){
				?>			
                  	<li><a href="<? the_permalink()?>" title="<? the_title()?>"><img src="<?= get_post_meta(get_the_ID(),'primary_image',true) ?>" title="<? the_title()?>" alt="<? the_title()?>" class="captify"/></a></li>
                <?
								}
						}
					}
				?>
                </ul>
                <a href="#" class="prev" id="prevs"></a>
                <a href="#" class="next" id="nexts"></a>
                <div class="clearfix"></div>
            </div>
        </div>
        <!-- End Sản phẩm đặc biệt -->
	   
        <!-- Sản phẩm bán chạy -->
        <div id="jk-best-seller">
        	<h2>Sản phẩm bán chạy</h2>
            <div class="jk_nav"></div>
            <div class="jk-list-product">
            	<ul id="best_sell_list">
                	<?php					
					$arg = array('post_type'         => 'san-pham',
								 'meta_key'          =>  'sanpham_banchay',
								 'meta_value' 	     => 'on',
                                 );
					$wp_query = new WP_Query($arg);
					
					if($wp_query->have_posts())
					{
						while($wp_query->have_posts())
						{
							$wp_query->the_post();
							
							if(get_post_meta(get_the_ID(),'primary_image',true) != '')
							{
				?>			
                  	<li><a href="<? the_permalink()?>" title="<? the_title()?>"><img src="<?= get_post_meta(get_the_ID(),'primary_image',true) ?>" title="<? the_title()?>" alt="<? the_title()?>" class="captify"/></a></li>
                <?
							}
						}
					}
				?>
                </ul>
                <a href="#" class="prev" id="prevs2"></a>
                <a href="#" class="next" id="nexts2"></a>
                <div class="clearfix"></div>
            
            </div>
        </div>
        <!-- End Sản phẩm bán chạy -->
       
       <!-- END HOME CONTENT -->
	   
	   <!-- SLIDER SETTINGS -->
	   <script type="text/javascript">
			$(window).load(function() {
				$('#slider').nivoSlider({
					effect:'random', //Specify sets like: 'fold,fade,sliceDown'
					slices:15,
					animSpeed:500,
					pauseTime:3000,
					startSlide:0, //Set starting Slide (0 index)
					directionNav:true, //Next & Prev
					directionNavHide:true, //Only show on hover
					controlNav:true, //1,2,3...
					controlNavThumbs:false, //Use thumbnails for Control Nav
					controlNavThumbsFromRel:false, //Use image rel for thumbs
					controlNavThumbsSearch: '.jpg', //Replace this with...
					controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
					keyboardNav:true, //Use left & right arrows
					pauseOnHover:true, //Stop animation while hovering
					manualAdvance:false, //Force manual transitions
					captionOpacity:0.7, //Universal caption opacity
					beforeChange: function(){},
					afterChange: function(){},
					slideshowEnd: function(){} //Triggers after all slides have been shown
				});
			});
			</script>

<?php get_footer(); ?>